<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>

<head>
<jsp:include page="${ctx}/css_inc"></jsp:include> 
<meta http-equiv="X-UA-Compatible" content="edge" /> 

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文件日志查询</title>
</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">

		<!-- Panel Other -->


		<div class="row">

			<div class="col-sm-12">

				<div class="ibox float-e-margins">
					
					<div class="ibox-title">
						<h5>文件日志</h5>
					</div>
					<div class="ibox-content">
						<div class="row">
							<div class="col-lg-12">
								<form role="form" class="form-inline" id="execFileLogForm">

									<div class="form-group">
										<div class="input-group">
											<span class="input-group-addon">文件名</span> 
											<input type="text" id="fileName" class="form-control" name="fileName">
										</div>
									</div>
									
									<div class="form-group">
									    <div class="input-group">
										<span class="input-group-addon">客群编号</span> 
										<input  type="text" id="customerId" class="form-control"  name="customerId" > 
										</div>
									</div>
									
									<div class="form-group">
										<select class="form-control" id="state">
											<option value="">请选择文件处理状态</option>
											<option value="1" id="state">处理中</option>
											<option value="10" id="state">处理完毕</option>
											<option value="-1" id="state">处理出错</option>
										</select>
									</div>
									
									<div class="form-group">
										<div class="input-group">
											<span class="input-group-addon">开始时间</span> 
										    <input id="execFileLogDateStart" class="laydate-icon form-control layer-date"  name="execFileLogDateStart" > 
										</div>
									</div>
									
									<div class="form-group">
										<div class="input-group">
											<span class="input-group-addon">结束时间</span> 
										    <input id="execFileLogDateEnd" class="laydate-icon form-control layer-date"  name="execFileLogDateEnd" > 
										</div>
									</div>
									
									<button id="queryBtn" class="btn btn-primary" type="button">
										<i class="fa fa-search"></i>&nbsp;搜索
									</button>
								</form>
							</div>
						</div>

						<div class="hr-line-dashed"></div>
						
						<div>
						<table id="execFileLogTable" data-height="452" data-mobile-responsive="true">
						</table>
						</div>
					
					</div>
				</div>
			</div>
			<!-- End Panel Other -->
		</div>
		
<jsp:include page="${ctx}/js_inc"></jsp:include>

 	<script type="text/javascript">
 	
 	laydate({
	    elem: '#execFileLogDateStart', 
	    event: 'focus' 
	});
 	
 	laydate({
	    elem: '#execFileLogDateEnd', 
	    event: 'focus' 
	});
 	
 	/* 日期的比较函数 */
 	function  CompareDate(d1,d2)
 	{
			//将所有的短横线替换为斜杠
			var boolDate = ((new Date(d1.replace("-","/"))) > (new Date(d2.replace("-","/"))));
			return boolDate;
 	}
 	
 	 /* 查询 */
			$('#queryBtn').click(
					function() {
						var startDate = $('#execFileLogDateStart').val();
					    var endDate = $('#execFileLogDateEnd').val();
					    if ((startDate != null && startDate != "") && (endDate != null && endDate !="") ) {
					    	if (CompareDate(startDate,endDate) == true) {
					    		swal('结束时间不能小于开始时间！', '', 'warning');
					    		return;
					    	};
					    }
						$('#execFileLogTable').bootstrapTable('showLoading')
								.bootstrapTable('refresh');
					});
			
			$('#execFileLogTable')
					.bootstrapTable(
							{
								columns : [
								     {
											field : 'state',
											title : '当前状态',
											halign : 'center', 
											align : 'center',
											formatter : function(value, row,index) {
												var html;
												switch (value) {
												case 1:
													html = '<span class="label ">处理中';
													break;
												case 10:
													html = '<span class="label label-primary">处理完毕';
													break;
												case -1:
													html = '<span class="label label-danger">处理出错';
													break;
												default:
													html = '';
												}
													return html;
											}

										},
										{
											field : 'logId',
											title : '文件日志ID',
											sortable : true,
											halign : 'center', 
											align : 'center',
										},
										{
											field : 'fileName',
											title : '文件名',
											halign : 'center', 
											align : 'center',
										},
										{
											field : 'customerId',
											title : '客群编号',
											halign : 'center', 
											align : 'center',
										},
										{
											field : 'fileVersion',
											title : '文件版本',
											halign : 'center', 
											align : 'center',
										},
										{
											field : 'startTime',
											title : '开始时间',
											halign : 'center', 
											align : 'center',
										},{
											field : 'endTime',
											title : '结束时间',
											halign : 'center', 
											align : 'center',
										}],
								sortName : 'logId',
								sortOrder : 'desc',
								pagination : true,
								striped : true,
								sidePagination : 'server',
								clickToSelect : true,
								pageNumber : 1,
								pageSize : 10,
								pageList : [ 10, 20 ],
								queryParamsType : '',
								queryParams : function(params) {
									
									return {
										fileName : $('#fileName').val(),
										customerId : $('#customerId').val(),
										state : $('#state').val(),
										execFileLogDateStart :  $('#execFileLogDateStart').val(),
										execFileLogDateEnd:  $('#execFileLogDateEnd').val(),
										pageNumber : params.pageNumber,
										pageSize : params.pageSize,
										sort : params.sortName,
										order : params.sortOrder
									};
								},
								url : '/contactmgn/filelog/queryExecFileLog'
							}); 
		</script>
</body>

</html>
